给定程序中,函数fun的功能是:找出形参s所指字符串中出现频率最高的字母(不区分大小写),并统计出其出现的次数。
例如,形参s所指的字符串为:abcAbsmaxless,程序执行后的输出结果为:
letter ’a’ : 3 times
letter ’s’ : 3 times
请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
#include
#include
void fun(char *s)
{ int k[26]={0},n,i,max=0; char ch;
while(*s)
{ if( isalpha(*s) ) {
ch=tolower(__1__);
n=ch-’a’;
k[n]+= __2__ ;
}
s++;
if(max }
printf("\nAfter count :\n");
for(i=0; i<26;i++)
if (k[i]==max) printf("\nletter \’%c\’ : %d times\n",i+’a’,k[i]);
}
main()
{ char s[81];
printf("\nEnter a string:\n\n"); gets(s);
fun(s);
}